<?php
include_once 'dbinfo.php';

session_start();

$title = $_POST['title'];
$content = $_POST['content'];
$username = $_SESSION['username'];

$link = mysqli_connect($dbhost,$dbusername,$dbpassword,$dbname,$dbport);
if(!$link){

    die("连接失败");
}

$sql = "insert into tb_articles (title,content,createtime,author,isdel) values('$title','$content',now(),'$username',0)";


$result = mysqli_query($link,$sql);

if($result){
    echo '发帖成功';
    header("Location: http://localhost/articles-demo1-php/php/article_list.php");
}else{
    echo '发帖失败';
    header("Location: http://localhost/articles-demo1-php/php/article_list.php");
}
mysqli_close($link);

?>